package jp.aist.gtrc.plus.scheduler.node;

import java.util.Map;

import jp.aist.gtrc.plus.scheduler.specific.pbs.status.PBSJobStatus;
import jp.aist.gtrc.plus.scheduler.status.NodeStatus;
import jp.aist.gtrc.plus.scheduler.util.Checker;


public class NodePropertiesChecker extends Checker<NodeInfo>{
        private String other;

        public NodePropertiesChecker(PBSJobStatus jobStatus) {
           this.other = jobStatus.getOtherResourceRequests();
        }

	public boolean isOK(NodeInfo node){

//System.out.println("Checking node " + node.getName() + " for " + this.other);
                if ( (this.other == null) || (this.other.equals("")) ) {
                   // no specific resource requested
                   return true;
                }

                NodeStatus status = node.getStatus();
                Map<String,String> propMap = status.getAttributeMap();

//                if ( (propMap == null) || (propMap.size() == 0) || (propMap.get("provisioned") == null) ) {
//                   // static compute node
//                   return true;
//                }
 
                if (propMap.get(this.other) == null) {
                   return false;
                }
               
System.out.println("Node " + node.getName() + " has property " + other);
                return true; 

	}

}
